package com.zh.dao;

import com.zh.domain.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;


public interface UserDao {
    /**
     *<insert id="add" parameterType="user">
     *INSERT INTO user VALUES (#{uuid},#{userName},#{password},#{realName},#{gender},#{birthday})
     *</insert>
     * @param user
     * @return
     */
    @Insert("INSERT INTO user VALUES (#{uuid},#{userName},#{password},#{realName},#{gender},#{birthday})")
    public boolean add(User user);
    /**
     * 删除用户
     * <delete id="delete" parameterType="int">
     * DELETE FROM user WHERE uuid = #{uuid}
     * </delete>
     * @param uuid
     * @return
     */
    @Delete("DELETE FROM user WHERE uuid = #{uuid}")
    public boolean delete(Integer uuid);
    /**
     * 求该用户
     * <update id="update" parameterType="user">
     * UPDATE user SET userName = #{userName}, password = #{password}, realName = #{realName}, gender = #{gender}, birthday = #{birthday} WHERE uuid = #{uuid}
     *</update>
     * @param user
     * @return
     */
    @Update("UPDATE user SET userName = #{userName}, password = #{password}, realName = #{realName}, gender = #{gender}, birthday = #{birthday} WHERE uuid = #{uuid}")
    public boolean update(User user);
    /**
     * 根据id查询
     * <select id="getById" resultType="user" parameterType="int">
     * SELECT*FROM user WHERE uuid = #{uuid}
     * </select>
     * @param uuid
     * @return
     */
    @Select("SELECT*FROM user WHERE uuid = #{uuid}")
    public User getById(Integer uuid);
    /**
     * 查询全部
     * <select id="getAll" resultType="user">
     * SELECT*FROM user
     * </select>
     * @return
     */
    @Select("SELECT*FROM user")
    public List<User> getAll();
    /**
     * 根据用户名和密码查询用户
     * <select id="getByUserNameAndPassword" resultType="user">
     *  SELECT*FROM user WHERE userName = #{userName} AND password = #{password}
     *\</select>
     * @param userName
     * @param password
     * @return
     */
    @Select("SELECT*FROM user WHERE userName = #{userName} AND password = #{password}")
    public User getByUserNameAndPassword(@Param("userName") String userName, @Param("password") String password);
}
